import type { siteTypes } from '@/common/types/SiteTypes';
import { defineStore } from 'pinia';
import { ref } from 'vue';
import { useTabbar } from './tabbar';

export const siteInfoData:siteTypes = {
    web_name: '',
    web_logo: '',
    web_home_logo: '',
    match_home_desc: '',
    match_home_desc2: '',
    web_home_num: '',
    vip_desc: '',
    vip_buy_money: '',
    vip_renew_money: '',
    theme_color: '#FD628D',
    theme_active_color: '#FD628D',
    page_title: null,
    tag_url: '',
    help_url: '',
    withdrawal_desc: [],
    report_list: [],
    tabbar_list: [],
    dealer: {
        dealer_level:10,
        dealer_level_one:"0",
        dealer_level_three:"0",
        dealer_level_two:"0",
        dealer_order_price:"0",
        dealer_status:"10",
    },
    dealer_apply: '10',
    match_home_man: '',
    match_home_woman: '',
}

export const useSite = defineStore('site', () => {
    // 站点信息
    const siteInfo = ref<siteTypes>({ ...siteInfoData })

    // 设置信息
    const setInfo = (data: siteTypes) => {
        // 储存数据
        siteInfo.value = data;
    }
    // 获取站点信息
    const getInfo = async () => {
        let info: siteTypes = { ...siteInfoData };
        info = await uni.$u.http.get("Index/config").then((res: any) => {
            return res?.data ?? null
        }).catch((err:any) => {
            console.log('123',err);
        });
        useTabbar().setTabbar(info.tabbar_list);
        setInfo(info);
    }
    return {
        siteInfo,
        getInfo,
    }
});